package tech.aistar.day02;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;

/**
 * 本类功能:
 *
 * @author cxylk
 * @date 2020/9/16 18:20
 */
@WebServlet(urlPatterns = "/day02/post")
public class PostAction extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //对于后台接收form表单发送过来的数据是
        //根据表单控件的name属性的值来接收的

        //进行Post请求中文的乱码问题
        req.setCharacterEncoding("utf-8");

        //后台永远是使用String来接收的
        String uname=req.getParameter("username");

        System.out.println("uname:"+uname);

        //获取多个参数
        String[] names=req.getParameterValues("name");
        if(names!=null){
            System.out.println(Arrays.toString(names));
        }
    }
}
